<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .a1 {
      width: 100px;
      height: 100px;
    }

    .h {
      background-color: green;
    }

    .b {
      background-color: blue;
    }
  </style>
</head>

<body>
  <!-- 一个div 点击按钮切换背景色 -->
  <div id="app">

    <div :class="{b:isn,h:!isn   }" class="a1"></div>
    <button @click="add">切换颜色</button>
  </div>
</body>
<script src="./vue.js"></script>
<script>
  const { createApp, ref } = Vue;
  createApp({
    setup() {



      let isn = ref(true)
      function add() {
        if (isn.value === true) {
          isn.value = false;

        } else {
          isn.value = true;

        }


      }

      return {
        add,
        isn

      }
    }


  }).mount('#app') 
</script>

</html>